home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / overview / moreisbetter / mib-libraries / morequickdraw / morequickdraw.cp next >
Encoding:
Text File  |  2000-06-23  |  2.4 KB  |  106 lines

  1. /*
  2.     File:        MoreQuickDraw.cp
  3.  
  4.     Contains:    
  5.  
  6.     Written by:    Pete Gontier
  7.  
  8.     Copyright:    Copyright © 1998 Apple Computer, Inc. All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.  
  20.          <4>      2/9/99    PCG     more TARGET_CARBON
  21.          <3>     1/22/99    PCG     TARGET_CARBON
  22.          <2>    11/11/98    PCG     fix header
  23.          <1>    11/10/98    PCG     first big re-org at behest of Quinn
  24.  
  25.     Old Change History (most recent first):
  26.  
  27.          <2>     8/28/98    PCG     add IsColorGrafPort
  28.          <1>     6/16/98    PCG     initial checkin
  29. */
  30.  
  31. #include "MoreQuickDraw.h"
  32.  
  33. #include <LowMem.h>
  34. #include <Gestalt.h>
  35.  
  36. static long gQuickDrawVersion;
  37.  
  38. pascal Boolean HaveColorQuickDraw (void)
  39. {
  40.     // the "features" selector is wrong; test the version instead
  41.     return gQuickDrawVersion > gestaltOriginalQD;
  42. }
  43.  
  44. pascal OSErr InitMoreQuickDraw (void)
  45. {
  46.     OSErr err = Gestalt (gestaltQuickdrawVersion,&gQuickDrawVersion);
  47.  
  48.     if (err == gestaltUndefSelectorErr)
  49.     {
  50.         gQuickDrawVersion = gestaltOriginalQD;
  51.         err = noErr;
  52.     }
  53.  
  54.     return err;
  55. }
  56.  
  57. pascal Boolean IsColorGrafPort (GrafPtr port)
  58. {
  59. #if TARGET_CARBON
  60. #    pragma unused (port)
  61.     return true;
  62. #else
  63.     // stolen from {CommonSystem}:Toolbox:ToolboxUtils:CommonHeaders:ColorUtils.h
  64.     return ((CGrafPtr) port)->portVersion < 0;
  65. #endif
  66. }
  67.  
  68. pascal OSErr ShowWatchCursor (void)
  69. {
  70.     OSErr err = noErr;
  71.  
  72.     CursHandle watchFob = GetCursor (watchCursor);
  73.  
  74.     if (!watchFob)
  75.         err = nilHandleErr;
  76.     else
  77.     {
  78.         Cursor preservedArrow;
  79.         GetQDGlobalsArrow (&preservedArrow);
  80.         SetQDGlobalsArrow (*watchFob);
  81.         InitCursor ( );
  82.         SetQDGlobalsArrow (&preservedArrow);
  83.     }
  84.  
  85.     return err;
  86. }
  87.  
  88. #if !TARGET_CARBON
  89.  
  90. pascal QDGlobalsPtr GetQDGlobalsPtr (void)
  91. {
  92.     return QDGlobalsPtr (* (Ptr*) LMGetCurrentA5 ( ) - 0xCA);
  93. }
  94.  
  95. #endif
  96.  
  97. pascal void SetArrowCursor (void)
  98. {
  99. #if TARGET_CARBON
  100.     Cursor arrow;
  101.     SetCursor (GetQDGlobalsArrow (&arrow));
  102. #else
  103.     SetCursor (&(qd.arrow));
  104. #endif
  105. }
  106.